// 引入路由组件
import Home from "@/pages/Home/Home"
import Login from "@/pages/Login/Login"
import Register from "@/pages/Register/Register"
import Search from "@/pages/Search/Search"
import Detail from "@/pages/Detail/Detail"
import AddCartSuccess from "@/pages/AddCartSuccess/AddCartSuccess"
import ShopCart from "@/pages/ShopCart/ShopCart"
import Trade from "@/pages/Trade/Trade"
import Pay from "@/pages/Pay/Pay"
// 配置路由信息
export default[
    {
        name:"home",
        path:"/home",
        component:Home,
        // showFooter控制是否展示Footer组件
        meta:{showFooter:true}
    },
    {
        name:"search",
        // keyword是为了params传参做的占位，“？”保证了params可传可不传
        path:"/search/:keyword?",
        component:Search,
        // showFooter控制是否展示Footer组件
        meta:{showFooter:true},
        // 路由组件传递props参数
        // 第一种：布尔值写法
        // props:true
        // 第二种:对象写法，额外的给路由组件传递一些props
        // props:{a:1,b:2}
        // 第三种：函数写法，可以传递params,query参数
        props:($route)=>{
            return {
                keyword:$route.params.keyword,
                k:$route.query.k
            }
        }

    },
    {
        name:"login",
        path:"/login",
        component:Login,
        
    }, 
    {
        name:"register",
        path:"/register",
        component:Register,
        
    },
    {
        name:"detail",
        path:"/detail/:skuid",
        component:Detail,
        meta:{showFooter:true}
    },
    {
        name:"addcartsuccess",
        path:"/addcartsuccess",
        component:AddCartSuccess,
        meta:{showFooter:true}
    },
    {
        name:"shopcart",
        path:"/shopcart",
        component:ShopCart,
        meta:{showFooter:true}
    },
    {
        name:"trade",
        path:"/trade",
        component:Trade,
        meta:{showFooter:true}
    },
    {
        name:"pay",
        path:"/pay",
        component:Pay,
        meta:{showFooter:true}
    },

    // 配置默认路由,打开页面首先指向的位置
    {
        path:"/",
        redirect:"/home"
    }
]